//
//  StoreRecomeViewController.swift
//  DSHCMerchant
//
//  Created by 罗德良 on 2018/4/12.
//  Copyright © 2018年 袋鼠好车. All rights reserved.
//

import UIKit

class StoreRecomeViewController: BaseViewController {
    let recomeCell = "recomeCell"
    
    @IBOutlet var recomeTopView: UIView!
    @IBOutlet var recomeTableview: UITableView!
    @IBOutlet var sgmentView: YJSegmentedControl!
    override func viewDidLoad() {
        super.viewDidLoad()
        initSegmentControl()
        configView()
    }

    func initSegmentControl() -> Void {
        let btnDataSource = ["维修收益","洗车收益","改装收益","保养收益","安装收益"]
    self.sgmentView = YJSegmentedControl.init(frame: CGRect(x:0,y:270,width:kScreenWidth,height:44), titleDataSource: btnDataSource, backgroundColor: UIColor.white, titleColor: BaseColor.DarkGrayColor, titleFont: UIFont.systemFont(ofSize: 14), select: BaseColor.NavColor, buttonDownColor: BaseColor.NavColor, delegate: self)
        self.view .addSubview(self.sgmentView)
    }
    
    func configView() -> Void {
        recomeTableview.delegate = self
        recomeTableview.dataSource = self
        recomeTableview.separatorStyle = .none
        recomeTableview.showsVerticalScrollIndicator = false
        //            appointmentTableview.backgroundColor = UIColor.color(.OXe1e1e1)
        recomeTableview.register(UINib(nibName: "StoreRecomeTableViewCell", bundle: nil), forCellReuseIdentifier: recomeCell)
        //        appointmentTableview.register(UINib(nibName: "OrderDidPayOrDidCrashTableViewCell", bundle: nil), forCellReuseIdentifier: orderWillOrCrashCell)
        //        appointmentTableview.cr.addHeadRefresh(animator: SlackLoadingAnimator() as CRRefreshProtocol) { [weak self] in
        //            self?.pageNum = 0
        //            self?.receiveOrderList(selctNum: self?.selectedNumber, page: self?.pageNum)
        //        }
        //        appointmentTableview.cr.addFootRefresh(animator: SlackLoadingAnimator() as CRRefreshProtocol)  { [weak self] in
        //            self?.pageNum += 1
        //            self?.receiveOrderList(selctNum: self?.selectedNumber, page: self?.pageNum)
        //        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

extension StoreRecomeViewController: YJSegmentedControlDelegate,UITableViewDelegate,UITableViewDataSource {
    
    func segumentSelectionChange(_ selection: Int) {
        print(selection)
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: recomeCell, for: indexPath) as! StoreRecomeTableViewCell
        cell.selectionStyle = .none
        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        //        if selectedNumber == 1 {
        //            return 115
        //        }else {
        //            return 185
        //        }
        return ScaleHeight(85)
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
    }
    
}

